import {
  AuthListResponse,
  CreateAuthParams,
  IAuth
} from '@/types/authority';

import { GET, POST } from '../index';

/**
 *  创建
 */
export const addAuth = (data: CreateAuthParams) => {
  return POST<CreateAuthParams, IAuth>('/api/v2/serve/permissions/add', data);
};
/**
 *  更新
 */
export const updateAuth = (data: CreateAuthParams) => {
  return POST<CreateAuthParams, IAuth>('/api/v2/serve/permissions/update', data);
};
/**
 *  删除
 */
export const delAuth = (data: Record) => {
  return POST<Record<string, string>, []>('/api/v2/serve/permissions/delete', data);
};
/**
 *  列表
 */
export const getAuthPage = (data: Record<string, any>) => {
  return POST<Record<string, any>, AuthListResponse>(
    `/api/v2/serve/permissions/query_page_like?page=${data.page || 1}&page_size=${data.page_size || 12}`,
    data,
  );
};
/**
 *  数据库
 */
export const get_connect_group = (data:  Record<string, any>) => {
  return POST<Record<string, any>>('/api/v2/serve/permissions/connect_all_list_group', data);
};
/**
 *  应用
 */
export const get_app_list = (data:  Record<string, any>) => {
  return POST<Record<string, any>>('/api/v2/serve/permissions/app_all_list', data);
};
/**
 *  工作流
 */
export const get_flow_list = (data:  Record<string, any>) => {
  return POST<Record<string, any>>('/api/v2/serve/permissions/flow_all_list', data);
};
/**
 *  知识库
 */
export const get_knowledge_group = (data:  Record<string, any>) => {
  return POST<Record<string, any>>('/api/v2/serve/permissions/knowledge_all_list_group', data);
};